/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package MobileArchitecture.impl;

import MobileArchitecture.Mobile;
import MobileArchitecture.MobileArchitecturePackage;
import MobileArchitecture.Server;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>System</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link MobileArchitecture.impl.SystemImpl#getMobile <em>Mobile</em>}</li>
 *   <li>{@link MobileArchitecture.impl.SystemImpl#getServer <em>Server</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SystemImpl extends NamedElementImpl implements MobileArchitecture.System {
	/**
	 * The cached value of the '{@link #getMobile() <em>Mobile</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMobile()
	 * @generated
	 * @ordered
	 */
	protected Mobile mobile;

	/**
	 * The cached value of the '{@link #getServer() <em>Server</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServer()
	 * @generated
	 * @ordered
	 */
	protected Server server;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SystemImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MobileArchitecturePackage.Literals.SYSTEM;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Mobile getMobile() {
		return mobile;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMobile(Mobile newMobile, NotificationChain msgs) {
		Mobile oldMobile = mobile;
		mobile = newMobile;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SYSTEM__MOBILE, oldMobile, newMobile);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMobile(Mobile newMobile) {
		if (newMobile != mobile) {
			NotificationChain msgs = null;
			if (mobile != null)
				msgs = ((InternalEObject)mobile).eInverseRemove(this, MobileArchitecturePackage.MOBILE__SYSTEM, Mobile.class, msgs);
			if (newMobile != null)
				msgs = ((InternalEObject)newMobile).eInverseAdd(this, MobileArchitecturePackage.MOBILE__SYSTEM, Mobile.class, msgs);
			msgs = basicSetMobile(newMobile, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SYSTEM__MOBILE, newMobile, newMobile));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Server getServer() {
		return server;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetServer(Server newServer, NotificationChain msgs) {
		Server oldServer = server;
		server = newServer;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SYSTEM__SERVER, oldServer, newServer);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setServer(Server newServer) {
		if (newServer != server) {
			NotificationChain msgs = null;
			if (server != null)
				msgs = ((InternalEObject)server).eInverseRemove(this, MobileArchitecturePackage.SERVER__SYSTEM, Server.class, msgs);
			if (newServer != null)
				msgs = ((InternalEObject)newServer).eInverseAdd(this, MobileArchitecturePackage.SERVER__SYSTEM, Server.class, msgs);
			msgs = basicSetServer(newServer, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileArchitecturePackage.SYSTEM__SERVER, newServer, newServer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MobileArchitecturePackage.SYSTEM__MOBILE:
				if (mobile != null)
					msgs = ((InternalEObject)mobile).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MobileArchitecturePackage.SYSTEM__MOBILE, null, msgs);
				return basicSetMobile((Mobile)otherEnd, msgs);
			case MobileArchitecturePackage.SYSTEM__SERVER:
				if (server != null)
					msgs = ((InternalEObject)server).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MobileArchitecturePackage.SYSTEM__SERVER, null, msgs);
				return basicSetServer((Server)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MobileArchitecturePackage.SYSTEM__MOBILE:
				return basicSetMobile(null, msgs);
			case MobileArchitecturePackage.SYSTEM__SERVER:
				return basicSetServer(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MobileArchitecturePackage.SYSTEM__MOBILE:
				return getMobile();
			case MobileArchitecturePackage.SYSTEM__SERVER:
				return getServer();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MobileArchitecturePackage.SYSTEM__MOBILE:
				setMobile((Mobile)newValue);
				return;
			case MobileArchitecturePackage.SYSTEM__SERVER:
				setServer((Server)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MobileArchitecturePackage.SYSTEM__MOBILE:
				setMobile((Mobile)null);
				return;
			case MobileArchitecturePackage.SYSTEM__SERVER:
				setServer((Server)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MobileArchitecturePackage.SYSTEM__MOBILE:
				return mobile != null;
			case MobileArchitecturePackage.SYSTEM__SERVER:
				return server != null;
		}
		return super.eIsSet(featureID);
	}

} //SystemImpl
